package car.aistar.service.impl;

import car.aistar.dao.CarOtherDao;
import car.aistar.entity.CarOther;
import car.aistar.service.CarOtherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (CarOther)表服务实现类
 *
 * @author makejava
 * @since 2020-10-02 21:33:59
 */
@Service("carOtherService")
public class CarOtherServiceImpl implements CarOtherService {
    @Autowired
    private CarOtherDao carOtherDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public CarOther queryById(Integer id) {
        return this.carOtherDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<CarOther> queryAllByLimit(int offset, int limit) {
        return this.carOtherDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param carOther 实例对象
     * @return 实例对象
     */
    @Override
    public CarOther insert(CarOther carOther) {
        this.carOtherDao.insert(carOther);
        return carOther;
    }

    /**
     * 修改数据
     *
     * @param carOther 实例对象
     * @return 实例对象
     */
    @Override
    public CarOther update(CarOther carOther) {
        this.carOtherDao.update(carOther);
        return this.queryById(carOther.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.carOtherDao.deleteById(id) > 0;
    }
}